package com.gamerole.prepare;

import com.gamerole.prepare.listener.WeChatListener;
import me.xuxiaoxiao.chatapi.wechat.WeChatClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
public class PrepareApplication {

    public static void main(String[] args) {
        SpringApplication.run(PrepareApplication.class, args);
    }

    @Bean
    WeChatListener getWeChatListener() {
        return new WeChatListener();
    }

    @Bean
    WeChatClient getWeChatClient(WeChatListener weChatListener) {
        //新建一个模拟微信客户端
        WeChatClient wechatClient = new WeChatClient();
        //为模拟微信客户端设置监听器
        wechatClient.setListener(weChatListener);
        //启动模拟微信客户端
        wechatClient.startup();
        return wechatClient;
    }
}
